﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RMS.Common;

namespace RMS
{
    public partial class DialogCheckAdmin : Form
    {
        public DialogCheckAdmin()
        {
            InitializeComponent();
            //Set Top Most
            this.TopMost = Constants.FullScreen();
        }
        public string result
        {
            get
            {
                return txtPass.Text.Trim();
            }
        }

        private void txtPass_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnLogin_Click(sender, e);
            }
            
            if (e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            var pass = txtPass.Text.Trim();

            if (Utilities.VerifyAdmin(pass))
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Bạn đã nhập sai mật khẩu. Xin vui lòng nhập lại.");
                txtPass.Clear();
                txtPass.Focus();
            }
            
        }
    }
}
